<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script>
			function $$(id){
				return document.getElementById(id)
			}
			window.onload=function(){
				var cnv=$$("canvas")
				var cxt=cnv.getContext("2d")
				
				cxt.beginPath()
				cxt.fillStyle="darkorange"
				cxt.fillRect(0,50,50,150)
				
				cxt.beginPath()				
				cxt.moveTo(50,50)
				cxt.lineTo(50,150)
				cxt.lineTo(250,150)
				cxt.closePath()
				cxt.lineWidth=5
				cxt.strokeStyle="red"
				cxt.stroke()
				
				cxt.beginPath()
				cxt.fillStyle="red"
				cxt.fillRect(60,90,50,50)
				cxt.moveTo(60,90)
				cxt.lineTo(110,90)
				cxt.lineTo(110,140)
				cxt.lineTo(60,140)
				cxt.closePath()
				cxt.lineWidth=1
				cxt.strokeStyle="green"
				cxt.stroke()
				
				cxt.beginPath()
				cxt.arc(150,53,35,0,180*Math.PI/180,true)
				cxt.lineWidth=10
				cxt.stroke()
				cxt.fillStyle="blue"
				cxt.fill()
				
				cxt.beginPath()
				cxt.arc(150,53,35,0,180*Math.PI/180,false)
				cxt.lineWidth=10
				cxt.strokeStyle="blue"
				cxt.stroke()				
				cxt.fillStyle="green"
				cxt.fill()
				
				var text="一些基础图形"
				cxt.font="bold 20px 微软雅黑"
				cxt.fillStyle="hotpink"
				cxt.fillText(text,250,120)
				
				$$("btn").onclick=function(){
					cxt.clearRect(60,90,20,20)
				}
				
				cxt.globalCompositeOperation="xor"
				cxt.fillStyle="hotpink"
				cxt.fillRect(400,30,50,50)
				cxt.beginPath()
				cxt.arc(450,100,40,0,Math.PI*2,true)
				cxt.closePath()
				cxt.fillStyle="lightblue"
				cxt.fill()
			}
		</script>
	</head>
	<body>
		<canvas id="canvas"width="500"height="150" style="border:1px dashed gray;"></canvas>
		<input id="btn" type="button" value="清除"/>
	</body>
</html>
